<template>
    <div>
        <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="100px">
            <el-form-item label="客户姓名" prop="cName">
                <el-input v-model="ruleForm.cName" placeholder="请输入客户姓名" style="width: 260px" readOnly="true"></el-input>
            </el-form-item>
            <el-form-item label="身份证号" prop="idcardNum">
                <el-input v-model="ruleForm.idcardNum" placeholder="请输入身份证信息" style="width: 260px" readOnly="true"></el-input>
            </el-form-item>
            <el-form-item label="送机时间" prop="postTime">
                <el-input
                        style="width: 260px"
                        v-model="ruleForm.postTime"
                        type="textarea"readOnly="true"
                ></el-input>
            </el-form-item>
            <el-form-item label="客户类型" prop="cType">
                <el-select v-model="ruleForm.cType"style="width: 260px">
                    <el-option label="家庭用户" value="1"  disabled="disabled"></el-option>
                    <el-option label="单位用户" value="2"  disabled="disabled"></el-option>
                    <el-option label="代理商" value="3"  disabled="disabled"></el-option>
                    <el-option label="签约用户" value="4" disabled="disabled"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="座机" prop="cCall">
                <el-input v-model="ruleForm.cCall"  style="width: 260px"readOnly="true"></el-input>
            </el-form-item>
            <el-form-item label="手机号" prop="phone">
                <el-input v-model="ruleForm.phone"  style="width: 260px"readOnly="true"></el-input>
            </el-form-item>
            <el-form-item label="邮编" prop="postNum">
                <el-input v-model="ruleForm.postNum"  style="width: 260px"readOnly="true"></el-input>
            </el-form-item>
            <el-form-item label="邮箱" prop="email">
                <el-input v-model="ruleForm.email" style="width: 260px"readOnly="true"></el-input>
            </el-form-item>
            <el-form-item label="单位名称" prop="unitName">
                <el-input v-model="ruleForm.unitName" style="width: 260px"readOnly="true"></el-input>
            </el-form-item>
            <el-form-item label="地址" prop="cAddress">
                <el-input type="textarea" v-model="ruleForm.cAddress" style="width: 260px"readOnly="true"></el-input>
            </el-form-item>
        </el-form>

    </div>
</template>
<script>
    import {getUserInfo as getUserInfo} from '../../api/client';

    export default {
        props:["cId"],
        data() {
            return {
                ruleForm: {
                    cId: "",
                    cName: "",
                    idcardNum: "",
                    postTime: "",
                    cType: "",
                    cCall: "",
                    phone: "",
                    postNum: "",
                    email: "",
                    unitName: "",
                    cAddress: "",
                    createTime: "",
                    active:"1"
                },
            }
        },
        created(){

            if(this.cId){
                let params = new URLSearchParams();
                params.append('cId', this.cId);
                this.getUserInfo(params);
                //this.buttonText="修改"
            }
            //this.getUserInfo();

        },
        components: {},
        methods: {

            resetForm(formName){
                this.$refs[formName].resetFields();
            },
            getUserInfo(params) {
                let that = this;
                // 执行方法
                getUserInfo(params).then(r=>{
                    console.log("进入");
                    console.log(r);
                    this.ruleForm.cName = r.cName
                    this.ruleForm.idcardNum=r.idcardNum;
                    this.ruleForm.postTime = new Date(r.postTime);
                    this.ruleForm.cType = r.cType + "";
                    this.ruleForm.cCall = r.cCall;
                    this.ruleForm.phone = r.phone;
                    this.ruleForm.postNum = r.postNum;
                    this.ruleForm.email = r.email;
                    this.ruleForm.unitName = r.unitName;
                    this.ruleForm.cAddress = r.cAddress;
                    this.ruleForm.active = r.active;

                }).catch(_=>{
                    console.log("获取客户信息失败！");
                })
            }
        }
    };
</script>